package com.tengroup.Controller;

import com.tengroup.entity.PracticeepEntity;
import com.tengroup.service.PracticeService;
import com.tengroup.vo.GeneratePracticeVo;
import com.tengroup.vo.PracticeVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/subjectQue")
public class PracticeController {
    @Autowired
    private PracticeService practiceService;

    @PostMapping("/scxlt")
    public List<PracticeepEntity> generatePractice(@RequestBody GeneratePracticeVo request) {
        return practiceService.generatePractice(request.getSubjectId(), request.getCount());

    }
    @GetMapping("/questions/{practiceId}")
    public List<PracticeepEntity> getQuestionsByPracticeId(@PathVariable Long practiceId) {
        return practiceService.findByPracticeId(practiceId);
    }

    // 提交答案并评分
    @PostMapping("/submit-and-grade")
    public List<PracticeepEntity> getAnswerAndJudge(@RequestBody PracticeVo practiceVo) {
        return practiceService.getAnswerAndJudge(practiceVo);
    }
}
